﻿/**
 * Virtual3DWorld 1: Create a Papervision and Box2D World based on a MovieClip
 *
 * Virtual3DWorld is (c) 2009 Gil Beyruth
 *
 * @author Gil Beyruth <http://www.midiadesigners.com.br>
 */
 package com.firstpixel.physics
{
	import Box2D.Collision.b2ContactPoint;
	import Box2D.Dynamics.b2ContactListener;
	
	import flash.display.MovieClip;
	
	public class ObjectContactListener extends b2ContactListener{
		public function ObjectContactListener (){
			
		}
		/**
		* Called when a contact point is added. This includes the geometry
		* and the forces.
		*/
	
		override public function Add(point:b2ContactPoint):void
		{
			trace("WOW CONTACT ADD!!"+point);
			trace("SHAPE 1:"+point.shape1);
			if(point.shape1.GetBody().GetUserData() is MovieClip){
				var movieClip1:MovieClip = point.shape1.GetBody().GetUserData() as MovieClip;
				trace("movieClip1 name : " + movieClip1.name );
				trace("movieClip1 : " + movieClip1 );
				if(movieClip1.material)trace("Sprite : " + movieClip1.material );
				
				
			}
			
			trace("SHAPE 2:" + point.shape2 );
			if(point.shape2.GetBody().GetUserData() is MovieClip){
				var movieClip2:MovieClip = point.shape2.GetBody().GetUserData() as MovieClip;
				trace( "movieClip2 name : " + movieClip2.name );
				trace( "movieClip2 : " + movieClip2 );
				if(movieClip2.material)trace("Sprite : " + movieClip2.material );
			}
			
			super.Add(point);
		}
		/**
		* Called when a contact point persists. This includes the geometry
		* and the forces.
		*/
		override public function Persist(point:b2ContactPoint) : void
		{
			trace("WOW CONTACT PERSIST!!"+point);
			
		}

		/**
		* Called when a contact point is removed. This includes the last
		* computed geometry and forces.
		*/
		override public function Remove(point:b2ContactPoint) : void
		{
			trace("WOW CONTACT REMOVE!!"+point);
			
		}
		

		
	}
}